package org.bird.reference;

/**
 * 强引用:只要引用存在,垃圾回收器永远不会回收
 * @VM args : -Xms5M -Xmx5M -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError
 * @author liangjf
 *
 */
public class StrongReference {

	@SuppressWarnings("unused")
	private static Object[] objArr1 = null;
	
	@SuppressWarnings("unused")
	private static Object[] objArr2 = null;

	public static void main(String[] args) throws InterruptedException {
		new StrongReference().fun();
		Thread.sleep(100000);
		System.out.println("增加objeArr2内存空间");
		objArr2 = new Object[10000];
		Thread.sleep(50000);
		System.out.println("释放objArr1内存空间");
		objArr1 = null;
		Thread.sleep(50000);
		System.out.println("释放objArr2内存空间");
		objArr2 = null;
	}

	public void fun() {
		objArr1 = new Object[100000];//强引用
	}
}
